<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>上下左右居中</title>
    <style type="text/css">
        html,body{
            height: 100%;
        }
        .wrap {
            background: url("images/bg.jpg") no-repeat center top;
            background-size: 100% 100%;
            height: 100%;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .center {
            background: green;
            width: 100px;
            height: 100px;
        }
    </style>
</head>
<body>
<div class="wrap">
    <div class="center"></div>
</div>
</body>
</html>
